#include "CacheMap.hh"
#include "Bug.h"
#include <iostream>
#include <iomanip>
#include <cassert>

Bug bug("test");
#ifdef DEBUG
int DEBUGTracker::depth = 1;
#endif


int main(void)
{

  const unsigned X = 10;
  const unsigned Y = 10;

  CacheMap toto;

  toto.init(X,Y,sqrt(5),sqrt(1.),10);

  bug << "attack reach map" << std::endl;

  for(unsigned i=0; i!=X; ++i)
    {
      for(unsigned j=0; j!=Y; ++j)
        bug << ' ' << toto.to_str(toto.to_uLocation(i,j));
      bug << '|';
      for(unsigned j=0; j!=Y; ++j)
        bug << ' ' << toto.to_str(toto.to_uLocation(i,j));
      bug << std::endl;
    }
  bug << std::endl;
  bug << std::endl;


  for(unsigned r=0; r!=X; ++r)
    {
      for(unsigned c=0; c!=Y; ++c)
        {
	  uLocation loc(toto.to_uLocation(r,c));
	  toto.visited.reset();
          bug << toto.to_str(loc) << ":" << std::endl;
	  for(CacheMap::reach_iterator it = toto.attack_begin(loc);
	      it != toto.attack_end(loc); ++it)
	    {
	      toto.visited.insert(*it);
	    }

	  for(unsigned i=0; i!=X; ++i)
	    {
	      for(unsigned j=0; j!=Y; ++j)
		if(toto.visited.count(toto.to_uLocation(i,j)))
		  bug << ' ' << toto.to_str(toto.to_uLocation(i,j));
		else
		  bug << ' ' << "(xx,xx)";
	      bug << std::endl;
	    }
	  bug << std::endl;
	}
    }
  bug << std::endl;



  return 0;
}
